package org.bite.lesson02;

public class Demo_207 {
    private static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException{
        Thread thread = new Thread(()->{
            while(!isQuit){
                System.out.println(Thread.currentThread().getName() + "hello");
            }
            System.out.println("线程结束咯");
        });
        System.out.println("线程是否存活：" + thread.isAlive());
        System.out.println("线程状态：" + thread.getState());
        System.out.println("线程是否中断：" + thread.isInterrupted());
        thread.start();
        Thread.sleep(100);
        isQuit = true;
        //等待线程销毁
        Thread.sleep(100);
        System.out.println("线程是否存活：" + thread.isAlive());
        System.out.println("线程状态：" + thread.getState());
        System.out.println("线程是否中断：" + thread.isInterrupted());
    }
}
